﻿@model Ninesky.Models.Content
@section Aside
    {
    @Html.Partial("AsidePartial")
}
<ol class="breadcrumb">
    <li><span class="glyphicon glyphicon-home"></span>  <a asp-page="/Manage/Index">首页</a></li>
    <li><a asp-page="/Member/Content/List">内容管理</a></li>
    <li class="active">修改内容</li>
</ol>
<div class="panel panel-default">
    <div class="panel-body">
        <form method="post" class="form-horizontal">
            <div asp-validation-summary="ModelOnly" class="text-danger"></div>
            <input type="hidden" asp-for="ContentId" />
            <input type="hidden" asp-for="ModuleType" />
            <div class="form-group">
                <label asp-for="CategoryId" class="control-label col-md-2 col-sm-2"></label>
                <div class="col-md-10 col-sm-10">
                    <div class="input-group">
                        <input type="text" asp-for="CategoryId" class="form-control" readonly>
                        <div class="input-group-btn">
                            <button type="button" id="ParentId_Text" class="btn btn-default" style="margin-left:auto;margin-right:auto">无</button>
                            <button type="button" id="ParentId_Btn" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">选择 <span class="caret"></span></button>
                            <div id="ParentId_Dropdown" class="dropdown-menu dropdown-menu-right">
                                <div>
                                    <ul id="ParentId_Tree" class="ztree" data-ns-url="/Member/Category/List?handler=GeneralByModuleType"></ul>
                                </div>
                            </div>
                        </div>
                    </div>
                    <span asp-validation-for="CategoryId" class="text-danger"></span>
                </div>
            </div>
            <div class="form-group">
                <label asp-for="Title" class="control-label col-md-2 col-sm-2"></label>
                <div class="col-md-10 col-sm-10">
                    <input asp-for="Title" class="form-control" />
                    <span asp-validation-for="Title" class="text-danger"></span>
                </div>
            </div>
            <div class="form-group">
                <label asp-for="Article.Keyword" class="control-label col-md-2 col-sm-2"></label>
                <div class="col-md-10 col-sm-10">
                    <input asp-for="Article.Keyword" class="form-control" />
                    <span asp-validation-for="Article.Keyword" class="text-danger"></span>
                </div>
            </div>
            <div class="form-group">
                <label asp-for="Article.Author" class="control-label col-md-2 col-sm-2"></label>

                <div class="col-md-10 col-sm-10">
                    <input asp-for="Article.Author" class="form-control" />
                    <span asp-validation-for="Article.Author" class="text-danger"></span>
                </div>
            </div>

            <div class="form-group">
                <label asp-for="Article.Source" class="control-label col-md-2 col-sm-2"></label>
                <div class="col-md-10 col-sm-10">
                    <input asp-for="Article.Source" class="form-control" />
                    <span asp-validation-for="Article.Source" class="text-danger"></span>
                </div>
            </div>
            <div class="form-group">
                <label asp-for="Article.Intro" class="control-label col-md-2 col-sm-2"></label>
                <div class="col-md-10 col-sm-10">
                    <textarea asp-for="Article.Intro" class="form-control"></textarea>
                    <span asp-validation-for="Article.Intro" class="text-danger"></span>
                </div>
            </div>
            <div class="form-group" data-ns-group="all">
                <label asp-for="Article.Content" class="control-label col-md-2 col-sm-2"></label>
                <div class="col-md-10 col-sm-10">
                    <textarea asp-for="Article.Content"></textarea>
                    <span asp-validation-for="Article.Content" class="text-danger"></span>
                </div>
            </div>
            <div class="form-group">
                <label asp-for="DefaultPicUrl" class="control-label col-md-2 col-sm-2"></label>
                <div class="col-md-10 col-sm-10">
                    <input asp-for="DefaultPicUrl" class="form-control" />
                    <span asp-validation-for="DefaultPicUrl" class="text-danger"></span>
                </div>
            </div>
            <div id="link_inputbox">
                <div class="form-group">
                    <label asp-for="LinkUrl" class="control-label col-md-2 col-sm-2"></label>
                    <div class="col-md-10 col-sm-10">
                        <input asp-for="LinkUrl" class="form-control" />
                        <span asp-validation-for="LinkUrl" class="text-danger"></span>
                    </div>
                </div>
            </div>
            <button type="submit" class="btn btn-primary col-md-offset-2 col-sm-offset-2">保存</button>
        </form>
    </div>
</div>

@section scripts{
    @await Html.PartialAsync("_ValidationScriptsPartial")
    <script src="~/lib/zTree/js/jquery.ztree.core.min.js"></script>
    <script src="~/lib/bootstrap3-dialog/dist/js/bootstrap-dialog.min.js"></script>
    <script src="~/lib/tinymce/tinymce.min.js"></script>
    <script src="~/lib/tinymce/langs/zh_CN.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            var nodes = [];
            var combotree;
            var setting = {
                data: {
                    simpleData: {
                        enable: true,
                        idKey: 'id',
                        pIdKey: 'pId',
                        rootPId: 0
                    }
                },
                callback: {
                    onClick: function (event, treeId, treeNode) {
                        $('#ParentId_Dropdown').hide();
                        $('#CategoryId').val(treeNode.id);
                        $('#ParentId_Text').text(treeNode.name);
                    }
                }
            };
            $.post('@Url.Content("~/Member/Category/GeneralByModuleType")', {type:1}, function (data) {
                $.each(data, function (index, category) {
                    nodes.push({ id: category.categoryId, pId: category.parentId, name: category.name, type: category.moduleType });
                });
                combotree = $.fn.zTree.init($('#ParentId_Tree'), setting, nodes);
                combotree.expandAll(true);
                $('#ParentId_Btn').click(function () { $('#ParentId_Dropdown').show() });
            });
            //编辑器
            tinymce.init({
                selector: '#Article_Content',
            });
        });
    </script>
}
@section css{
    <link href="~/lib/zTree/css/metroStyle/metroStyle.css" rel="stylesheet" />
    <link href="~/lib/bootstrap3-dialog/dist/css/bootstrap-dialog.min.css" rel="stylesheet" />
}